package com.bds.btcdc.service;

import com.bds.btcdc.model.CoinPairExchanges;
import com.bds.btcdc.model.TransactionRecord;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by DongChenchen on 2018/5/17 0017
 * 各交易所交易记录
 */
@Service
public class TransactionRecordService extends BaseService<TransactionRecord>{
    /**
     *
     * @param exchange
     * @param tid 交易生成ID
     * @return
     */
    public TransactionRecord  getByExchangeAndTid(String exchange,Long tid) {
        Sql sql = Sqls.create("Select a.* from t_transaction_record a " +
                "where a.exchange=@exchange and a.tid=@tid");
        sql.params().set("exchange", exchange);
        sql.params().set("tid", tid);
        sql.setCallback(Sqls.callback.entity());
        sql.setEntity(dao.getEntity(TransactionRecord.class));
        dao.execute(sql);
        return sql.getObject(TransactionRecord.class);
    }
}
